package com.woniuxy.controller;

import com.woniuxy.entity.PaperClassEntity;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.entity.StudentsEntity;
import com.woniuxy.service.PaperClassService;
import com.woniuxy.service.StudentsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags="学生管理")
@RestController
@RequestMapping("/studentsManage")
public class StudentsController {
    @Autowired
    StudentsService studentsService;

    @ApiOperation("根据当前页，每页条数查询数据")
    @GetMapping("/findAll/{currentPage}/{pageSize}")
    public ResponseEntity findAll(@PathVariable int currentPage, @PathVariable int pageSize){
        return  studentsService.findAll(currentPage, pageSize);
    }
    @ApiOperation("根据学生id，查询考试记录表，获取记录")
    @GetMapping("/findErecord/{studentId}")
    public ResponseEntity findErecord(@PathVariable int studentId){
        return  studentsService.findErecord(studentId);
    }

    //根据id，删除试卷菜单中的指定类别

    @ApiOperation("删除学生信息")
    @GetMapping("/delete/{id}")
    public ResponseEntity deleteStudent(@PathVariable("id") int id){
        return studentsService.deleteById(id);
    }
    /*批量删除*/

    @ApiOperation("批量删除")
    @PostMapping("/batchdelete")
    public ResponseEntity batchDelete(@RequestBody StudentsEntity studentsEntity){
        return studentsService.batchDelete(studentsEntity);
    }
//    添加学生

    @ApiOperation("添加学生")
    @PostMapping("/insertStudent")
    public ResponseEntity insertStudent(@RequestBody StudentsEntity studentsEntity){
        return studentsService.insertStudent(studentsEntity);
    }

    /**在修改前需要把原本的内容查询出来，渲染到页面上*/
    @ApiOperation("修改学生信息之前")
    @PostMapping("/updateBefore")
    public ResponseEntity updateBefore(@RequestBody StudentsEntity studentsEntity){
        return studentsService.updateBefore(studentsEntity);
    }


    /**根据数据库id修改试卷分类*/
    @ApiOperation("修改学生信息")
    @PostMapping("/updateStudent")
    public ResponseEntity updateStudent(@RequestBody StudentsEntity studentsEntity){
        return studentsService.updateStudent(studentsEntity);
    }
    /**   按试卷分类名称搜索*/

    @ApiOperation("按学生姓名搜索")
    @PostMapping("/searchStudent")
    public ResponseEntity searchStudent(@RequestBody StudentsEntity studentsEntity){
        return studentsService.searchStudent(studentsEntity);
    }


}
